/*
 *  Project     : QKeyboardStatistic
 *  Author      : Durachenko Aleksey V. <durachenko.aleksey@gmail.com>, 2011
 *  Licence     : GNU GENERAL PUBLIC LICENSE Version 2
 */
#ifndef CDATABASE_H
#define CDATABASE_H

#include <QtSql>
#include <QObject>
#include <QDateTime>
#include "global.h"

class CDatabase : public QObject
{
Q_OBJECT
public:
    CDatabase(QObject* parent);
    bool open(const QString& fileName);
    bool isOpen() const;
    bool writeTrio(const QDateTime& dateTime, qint64 key, qint64 click, qint64 mileage);
    bool getTotalStatistic(qint64& key, qint64& click, qint64& mileage);
    bool getMonthStatistic(const QDateTime& dateTime, qint64& key, qint64& click, qint64& mileage);
    bool getWeekStatistic(const QDateTime& dateTime, qint64& key, qint64& click, qint64& mileage);
    bool getDayStatistic(const QDateTime& dateTime, qint64& key, qint64& click, qint64& mileage);
    bool getHourStatistic(const QDateTime& dateTime, qint64& key, qint64& click, qint64& mileage);

private:
    QSqlDatabase mDb;
};

#endif
